<template>
  <dt-modal-edit
    ref="modal"
    title="入账公司修改"
    :label-width="90"
    :width="450"
    @ok="onOk"
    :loading="loading"></dt-modal-edit>
</template>

<script>
  import Opt from '../opt/CompanyOpt.js'
  import informationMgr from '@/biz/commission/information.js'

  export default {
    data() {
      return {
        loading: false,
        info: {}
      }
    },
    methods: {
      show(info) {
        this.info = info
        this.$refs.modal.show(new Opt(this.info))
      },
      hide() {
        this.$refs.modal.hide()
      },
      onOk() {
        this.loading = true
        informationMgr
          .updateCompany({
            commissionId: this.info.commissionId,
            housesId: this.info.housesId,
            accountingCompany: this.info.accountingCompany
          })
          .then((res) => {
            this.$Message.success('入账公司修改成功')
            this.loading = false
            this.$emit('success', this.info.accountingCompany)
            this.hide()
          })
          .catch(() => {
            this.loading = false
          })
      }
    }
  }
</script>

<style></style>
